const Mock = require('mockjs')
const express = require('express')
const router =express.Router()
const SortModel = require('../models/sort')

router.get('/getSort',(req,res,next)=>{
  
    SortModel.find().then(result=>{
      res.json({
          code:200,
          data:result,
          message:'全局查询成功',
      })
  })
})


router.post('/setSort',(req,res,next)=>{
  const {sort_name,sort_item} = req.body

  const sort = new SortModel({
      sort_name,
      sort_item:sort_item.split(','),
  })
  sort.save().then(result => {
      res.json({
          code:200,
          data:result,
          message:'创建完成',
      })
  })
})

module.exports = router